package com.ruoyi.subject.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.subject.domain.QbExamAnalyse;
import com.ruoyi.subject.domain.QbExamRecord;
import com.ruoyi.subject.service.IQbExamRecordService;
import com.ruoyi.subject.service.IQbSubjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 模拟考试分析Controller
 *
 * @author lzhj
 * @date 2021-01-20
 */
@Api(tags = "模拟考试分析")
@RestController
@RequestMapping("/qb/examAna")
public class QbExamAnalyseController extends BaseController {
    @Autowired
    private IQbSubjectService qbSubjectService;

    @Autowired
    private IQbExamRecordService qbExamRecordService;

    /**
     * 查询模拟考试分析列表
     */
    @ApiOperation(value = "查询模拟考试分析列表,分页。qb:examAna:list'")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "pageNum", value = "当前记录起始索引", dataType = "int", paramType = "path"),
            @ApiImplicitParam(name = "pageSize", value = "每页显示记录数", dataType = "int", paramType = "path"),
    })
    @PreAuthorize("@ss.hasPermi('qb:examAna:list')")
    @GetMapping("/list")
    public TableDataInfo list(QbExamAnalyse qbExamAnalyse) {
        startPage();
        List<QbExamAnalyse> list = qbExamRecordService.selectExamAnalyseList(qbExamAnalyse);
        return getDataTable(list);
    }

    /**
     * 查询考模拟考试明细
     */
    @ApiOperation(value = "查询考模拟考试明细，qb:examAna:xqList")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "pageNum", value = "当前记录起始索引", dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "每页显示记录数", dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "userId", value = "用户id", dataType = "long", paramType = "query"),
            @ApiImplicitParam(name = "category", value = "人员类别", dataType = "string", paramType = "query"),

    })
    @GetMapping("/xqList")
    @PreAuthorize("@ss.hasPermi('qb:examAna:xqList')")
    public TableDataInfo xqList(long userId, String category) {
        startPage();
        QbExamRecord qbExamRecord = new QbExamRecord();
        qbExamRecord.setUserId(userId);
        qbExamRecord.setSubType(category);
        List<QbExamRecord> list = qbExamRecordService.selectQbExamRecordList(qbExamRecord);
        return getDataTable(list);
    }

}
